<template>
    <div style="display: block;">
        <HomeView></HomeView>
        <!-- <h3>热门推荐</h3> --> 
       <div class="select">
            <el-input v-model="input" placeholder="请输入选择的颜色" style="width: 200px;" suffix-icon="el-icon-search" disabled></el-input>
            <el-button type="primary" plain @click="select">筛选</el-button>
            <el-button type="success" plain @click="update">重置</el-button>
        </div>
        <div v-for="(item,index) in vehicles">
            <li class="item">
                <div class="img_box"><img v-bind:src="item.image" alt="" @click="docs(item.id)"></div>
                <p v-html="item.brand"></p>
                <span :style="{color:'red'}">&yen;{{item.price}}</span>
                <br>
                <span :style="{color:'red'}">{{item.address}}</span>
            </li>
        </div>
    </div>
</template>

<script>
import HomeView from '@/views/HomeView.vue';

export default {
    components:{
        HomeView
},
        data() {
            return{
                input:'',

                vehicles:[{}]
        }
    },
    methods: {
        select(){
            this.$axios.post('/car/selectColor',{

                color:this.input
            },
            {
              headers:{
                "token":JSON.parse(localStorage.getItem('user')).token
              } 
              })
            .then(response =>{
                this.vehicles = response.data.data;
            })
        },
        update(){
            // this.imput:null
            this.input='',
            this.select()
        },
        docs(vehicle_id){
            console.log("-------")
            console.log(vehicle_id)
            console.log("-------")
            this.$router.push({
			          name: 'order',
			          params: {
			            vehicle:this.vehicles[vehicle_id]
			          }
			        });
                    

        },
    },
    mounted() {
            this.vehicles = JSON.parse(localStorage.getItem('car'));
        }
}
</script>

<style>
 
 
        .item {
            float: left;
            width: 23%;
            height: 266px;
            margin: 0 5px 8px;
            text-align: center;
            background: #fff;
        }
 
        .item .img_box {
            width: 80%;
            height: 120px;
            margin: 30px auto;
        }
 
        .img_box img {
            width: 100%;
            height: 100%;
        }
 
        .item p {
            font-size: 12px;
            line-height: 20px;
            height: 40px;
            padding: 0 10px;
            /* white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis; */
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
 
        .more2_info_self {
            background-color: #e1251b;
            border-radius: 2px;
            color: #fff;
            padding: 0 5px;
            margin-right: 4px;
            line-height: 16px;
            height: 16px;
            html{font-size: 12px;}
            font-style: normal;
        }

</style>